package cn.xorange.commons.utils.captcha;

import cn.xorange.commons.utils.configuration.constants.UtilsErrorCode;
import cn.xorange.commons.utils.lang.StringUtils;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;

import java.io.Serializable;


/**
 * @author yangjian
 */
@Data
public class Captcha implements Serializable {

    public Captcha(String uuid){
        this.uuid = uuid;
    }
    public Captcha(String uuid, String cap, String code){
        this.uuid = uuid;
        this.cap = cap;
        this.code = code;
    }

    public Captcha(UtilsErrorCode errorCode){
        this.status = errorCode.getStatus();
        this.sysCode = errorCode.getCode();
        this.msg  = errorCode.getMsg();
    }

    public Captcha(Integer status, Integer sysCode,String msg){
        this.status = status;
        this.sysCode = sysCode;
        this.msg = msg;
    }

    private String uuid;
    private String cap;

    @JSONField(serialize = false)
    private String code;

    //返回状态和错误信息
    @JSONField(serialize = false)
    private Integer status;
    @JSONField(serialize = false)
    private Integer sysCode;
    @JSONField(serialize = false)
    private String msg;

    public String cacheKey(){
        return StringUtils.format("captcha:{}", uuid);
    }

}
